package hanqi.jdbc;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

@Repository
public abstract class CustomerDaoImpl implements CustomerDao {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    public int saveCustomer(Customer customer) {
        String sql = "insert into damn.ai(jobNo,name,departMent)values(?,?,?)";
        int result = jdbcTemplate.update(sql,new Object[] {customer.getJobNo(),customer.getName(),customer.getDepartment()});
        return result;
    }
    public Customer getCustomer(Integer id) {
        String sql = "select * from damn.ai where id=?";
        return jdbcTemplate.queryForObject(sql,new BeanPropertyRowMapper<Customer>(Customer.class),id);
    }
}
